import pgzrun
import random

ROWS = 50
COLS = 50
CELL_SIZE = 15

HEIGHT = (ROWS * CELL_SIZE)
WIDTH  = (COLS * CELL_SIZE)

BACK_COLOR = (0, 0, 127)
CELL_COLOR = (0, 200, 0)

class LifeGame:
    def __init__(self):
        self.world = self.init_map(ROWS, COLS)

    def init_map(self, rows, cols):
        return [[0 for c in range(cols)] for r in range(rows)]

    def random_map(self):
        for r in range(ROWS):
            for c in range(COLS):
                self.world[r][c] = int(random.randint(0, 7) == 0)

    def draw_world(self):
        for r in range(ROWS):
            for c in range(COLS):
                if self.world[r][c] == 1:
                    draw_cell(r, c)

def draw_cell(r, c):
    cx = CELL_SIZE * c
    cy = CELL_SIZE * r
    cell_rect = Rect((cx, cy), (CELL_SIZE, CELL_SIZE))
    screen.draw.filled_rect(cell_rect, CELL_COLOR)

def update():
    pass

def draw():
    screen.fill(BACK_COLOR)
    game.draw_world()

game = LifeGame()
game.random_map()

pgzrun.go()